数学代数教学总结

时间:2019-02-26 18:15:26 总结 我要投稿

数学代数教学总结

  在学习vb过程中,很多同学简单地认为布尔值true就是—1或非0值,false就是0,这种看法是错误,下面将布尔值、逻辑运算和关系运算总结如下:

数学代数教学总结

  在vb中,布尔(boolean)值有两个:true(真)和false(假),布尔值可以用于逻辑、关系(比较)和算术运算中。

  1)布尔值用于逻辑运算中,结果为布尔值。

  例如:

  print not true, not false

  print true and true, true and false, false and true, false and false

  print true or true, true or false, false or true, false or false

  结果为:

  false true

  true false false false

  true true true false

  【总结】

  not 非运算规则:非真则假,非假则真

  and 与运算规则:只有都是true,结果才为true(只要有一个为false,结果就为false)

  or 或运算规则:只有都是false,结果才为false(只要有一个为true,结果就为true)

  2)布尔值用于关系(比较)运算中,结果为布尔值。

  例如:

  print true > false

  结果为:

  false

  【总结】在关系运算中,true小于false。

  3)布尔值用于算术运算中(true当作—1,false当作0),结果为数值型。

  例如:

  print true + 3, false + 3

  结果为:2· 3

  1)逻辑运算说明

  数值用于逻辑运算中,非0值当作true,0当作false,结果为数值型。

  注:true and n和false or n的结果为n,其他情况true写成—1,false写成0(即结果可能为n、—1或0)

  例如:

  print true and 5, true and 0, false and 5, false and 0

  print true or 5, true or 0, false or 5, false or 0

  结果为: 5 0 0 0

  —1 —1 5 0

  【注意】布尔值可用于算术运算;数值可以用于逻辑运算。但不能认为true和—1、false和0完全等价。

  ● 算术运算的'结果必然为数值型。

  ● 关系运算(比较运算)的结果必然是布尔值。

  ● 逻辑运算的结果可能是布尔值或是数值型。

  2)关系(比较)运算说明

  数值、日期、字符和布尔值都可以比较。

  ● 日期比较的规则是“日期在后的大”

  ● 字符比较的规则是按照ascii码比较,空格<"0"—"9"<"a"—"z"<"a"—"z"<汉字

  ● 布尔值比较的规则是假大于真。

  例如:

  print 3 < 5

  print #9/19/2009# > #9/18/2009#

  print "abc" > "abcd"

  print true > false

  结果为:

  true

  true

  false

  false

  例题:(16)设a=4,b=3,c=2,d=1,下列表达式的值是

  a>b+1 or c<D p c< mod b and>

  a)true b)1 c)—1 d)0

  【分析】

  a>b+1 即 4>3+1 结果为 false。

  c<D p false。< 结果为 2<1>

  b mod c即3 mod 2结果为 1。

  即false or false and 1。and优先级高于or,false and 1结果为0。

  false or 0的结果为0。

  所以本题答案为0 。

【数学代数教学总结】相关文章:

1.数学教学总结

2.初中数学教学总结

3.数学教学反思总结

4.数学教学总结4篇

5.数学教学总结三篇

6.2021小学数学教学总结

7.高二数学教学总结

8.初三数学教学总结